home *** CD-ROM | disk | FTP | other *** search
/ Workbench Add-On / Workbench Add-On - Volume 1.iso / BBS-Archive / DiskUtil / Crunch / XFH.lha / XFH / ADVANCED_USAGE.DOC < prev    next >
Text File  |  1994-05-06  |  25KB  |  511 lines

  1.  
  2.  
  3.                   Xpk File System Handler v1.39
  4.  
  5.                       By Kristian Nielsen
  6.  
  7.  
  8. This package may be distributed freely for non-commercial purposes along
  9. with Xpk or on its own, provided that all files and subdirectories are
  10. left intact. However, all rights remain with the author. And as usual,
  11. the author will in no way be held responsible for any damage, directly,
  12. implicit or otherwise, resulting from the use of this program. After
  13. all, you get this program for free; use it or not as you like, and at
  14. your own risk. 
  15.  
  16. The file 'XFH.doc' (which should be distributed alone with this file)
  17. gives information on how to get started quickly while this text gives
  18. a more technical discussion of the XFH file system handler and
  19. describe some of the more obscure options that are not accessible
  20. through the gui. Some knowledge of the more technical aspects of the
  21. Amiga is assumed. Also, this document is pretty unstructured, being
  22. just a random collection of notes gathered together over the last year
  23. of XFH development. Do read XFH.doc first to get an overview of what
  24. XFH is. A lot of users probably don't wan't to read this file at all;
  25. XFH.doc will tell them all they need to know.
  26.  
  27.  
  28.                               --- O ---
  29.  
  30.  
  31. What's possible.
  32.  
  33.    XFH, when used with Xpk, makes it possible to store data in compressed
  34. format without this being visible to the user or to application programs -
  35. XFH will make the compressed data appear like ordinary files. This is by
  36. no means a new idea. In MS-DOS world, a (commercial) program called
  37. 'Stacker' has been available for some time, which makes it possible to
  38. compress a whole partition on a harddisk. On the amiga, people have long
  39. used powerpacker along with programs like PPMore to store data files in
  40. packed formats (but relying on the application to recognise that the file
  41. is in compressed format), and programs like PPPatch have been used to
  42. change dos.library to recognise the powerpacker format automatically.
  43. However, none of these approaches are perfect in all situations, and so
  44. there is room for another alternative - the XFH.
  45.  
  46.    XFH works in conjuction with the Xpk approach to data compression. This
  47. in itself gives a number of advantages - a flexible interface to the 
  48. compressing algorithms, lots of different packers available with the
  49. possibility to add new ones etc. But compared to approaches like 
  50. 'Stacker', there is an additional advantage: access to the compressed 
  51. data is not limited to XFH - most of the time, the XFH way will be the 
  52. most convenient way to access data, but if needed, the complete range of 
  53. Xpk applications is available to the user. The file orientated nature of 
  54. Xpk also means that XFH - like PPPatch etc., but unlike Stacker - will 
  55. co-exists nicely with any other Amiga filing system without the need to 
  56. set up any new partitions or prepare the disk with a special program. In 
  57. fact, if you happened to have a CD-Rom (read only) stuffed with 
  58. powerpacked files (or any other format that the current version of Xpk 
  59. supports), you could dump an XFH unit on top of it and largely forget 
  60. about the disk being compressed from then on.
  61.  
  62.    So, what is possible is to mount a XFH unit on top of each of one or
  63. more standard AmigaDOS directories. It is now possible for programs to
  64. access the directories as usual, data being decompressed and optionally
  65. compressed as needed in a completely transparent way - programs will
  66. never know the difference between compressed and uncompressed files -
  67. while still having access to the compressed data using conventional
  68. compress/uncompress programs. So the dream is that of doubling the
  69. capacity of your hard- or floppydisks for zero cost. 
  70.  
  71.    As an example of the possibilities of the XFH, I have been using it
  72. for holding various doc files, metafont sources and little used emacs
  73. scripts and shell commands on HD, saving in the order of perhaps 60%
  74. file space with no noticeable degrading of overall system performance.
  75.  
  76.  
  77.                               --- O ---
  78.  
  79.  
  80. What is the catch?
  81.  
  82.    Of course, as everyone knows, nothing comes for free. Obviously,
  83. there is a speed penalty to compressing or uncompressing a file.  This
  84. speed penalty will be highly dependent on the actual compression
  85. algorithm and data media used; for example an algebraic compression
  86. scheme used with a superfast HD will probably be rather slow, while a
  87. fast algorithm may actually result in a speed-up of floppy access since
  88. the disk access time saved by the smaller file size more that accounts
  89. for the time taken decompressing. And of course with the coming of ever
  90. more powerful CPU's the speed will be less of a problem. Some things
  91. will always be slow, though. Especially directory listning is a
  92. problem, since every single file has to be opened in order to check
  93. whether the file is compressed or not. In fact, I'll admit that running
  94. XFH from floppy on an unaccelerated amiga will sometimes seem a bit
  95. slow. However, XFH was not written to be as fast and small as possible,
  96. but rather to be flexible and expandable. And I'm sure a lot of users
  97. will find it very useful even on 'small' amigas. On an A3000, XFH runs
  98. like a dream, of course. And there is still the possibility for speed
  99. improvements in later versions. 
  100.  
  101.    Aside from the problem of speed, V1.39 of the XFH comes with a few 
  102. other limitations that I'm hoping to remove in later versions. Most 
  103. important is the lack of some of the new 2.0 packets, a lack that will 
  104. become more severe as more 2.0-only programs start to depend on these 
  105. packets. Another problem is that XFH in the present version is somewhat 
  106. memory-hungry, in that it will keep any compressed file completely 
  107. unpacked in memory as long as that file is open. This is mostly due to 
  108. limitations in the current Xpk interface, and I'm hoping to remove this 
  109. in a later release. However, currently this means that it is impossible 
  110. to open a compressed file if it is larger than available memory.
  111. [One way to solve this would be to have XFH use one of the 'virtual
  112. memory' programs that are starting to appear. In fact, I have had one
  113. or two reports about this actually working. If someone wants to
  114. discuss this I'd very much wellcome it.]
  115.  
  116.    A number of other problems to look out for are detailed in a later 
  117. section in this doc file. Most of these are things that could be fixed in 
  118. later versions.
  119.  
  120.  
  121.  
  122.                               --- O ---
  123.  
  124.  
  125. Instructions for use.
  126.  
  127.    XFH is implemented as an AmigaDOS device handler. The 'L:'
  128. directory contains examples of other such device handlers, and this is
  129. usually also the best place to put XFH (the file 'XFH-Handler', to be
  130. precise). Like other handlers, XFH must be mounted before it can be
  131. used. This can be done by creating an entry for it in the
  132. 'DEVS:Mountlist' file (just the mountlist for short) and issuing the
  133. command 'Mount <device>', where <device> is the name given to the
  134. device in the mountlist. The supplied file 'Devs/Mountlist.custom'
  135. contains example entries for the XFH; it might be convenient to append
  136. this file to the end of 'DEVS:Mountlist' (the entries assume an assign
  137. 'xfhdir:' to the XFH distribution directory). The most important part
  138. of each mountlist entry is the Device name (XH1: etc) and the 'Startup'
  139. entry, since these are used to configure the various options of XFH..
  140. Further information on the mechanism of mountlists and handlers in
  141. general can be found in various places; I will not attempt any lenghty
  142. explanation here.
  143.  
  144.    Unlike most other 'normal' device handlers, XFH needs additional 
  145. information to function correctly. Most importantly it needs to be told 
  146. what directory it should use as its root directory (that is, where it 
  147. should look for compressed files). In the simplest case, this can be done 
  148. by having an assigning (or device volume name)  'nn:' to this
  149. directory and mounting an XFH partition with the name 'Xnn:' (any
  150. letter will do, not just 'X'). However, XFH also provides 'options',
  151. some of which cannot be controlled by the gui but only through the
  152. Mountlist or by using Arexx.
  153.  
  154. Options can be specified in the mountlist or in an option file, and
  155. can be changed dynamically using AREXX. An option is specified as a
  156. string following the same conventions as the TOOLTYPES of the
  157. Workbench.
  158.  
  159. If the number of options that should be set are limited, it can be
  160. convenient to put them directly in the mountlist entry. This is done
  161. by using the 'Startup' keyword. Use a line of the form
  162.  
  163.     Startup = "!<opt1>=<value1>!<opt2>=<value2>...!<optN>=<valueN>"
  164.  
  165. (that is, a list of option assignments preceded by '!' (no spaces).
  166. The '"'s are optional and the '='s can be replaced with '&'s (this is
  167. nessesary to be compatible with some mount commands). See the entry
  168. for 'XH0:' in 'Devs/Mountlist.custom' for an example.
  169.  
  170. For a larger number of options, option files should be used. XFH has
  171. the concept of primary and secondary option files.  The primary option
  172. file is used by putting a line of the form
  173.  
  174.     Startup = xfhdir:optionfiles/.xfhrc_1
  175.  
  176. into the mountlist entry (distinguised from the other use of this
  177. keyword by the fact that no '!' appears). The filename can be anything
  178. you like, of course. The secondary option file is named '.xfhrc' and
  179. is placed in the root directory of the XFH unit (uncompressed!).  The
  180. settings in the secondary option file overrides any settings in the
  181. primary option file, but there are some restrictions on the options
  182. that can be used in the secondary option file, see below.  Both files
  183. are optional, the handler will pick default values for any options
  184. that are not set by the user.
  185.  
  186. In the option files, options are given each on a line of its own. Some
  187. examples are given in the directory 'Optionfiles'. Be careful when
  188. using the secondary option file; this is also used by XFH itself to
  189. store information that must be preserved across reboots (notably the
  190. volume name for Relabel).
  191.  
  192. When the handler is mounted, most options can be changed by sending an
  193. approproate AREXX command to the handler. The name of the port is the
  194. same as the name of the device, though this can be changed (see
  195. below). Note that XFH will refuce to mount if it cannot open the AREXX
  196. port because of a naming conflict. To set an option, send a command
  197.  
  198.     SETOPTION <optstring>
  199.  
  200. to the port, where <optstring> should be in the same format as that
  201. used in option files. The directory 'Arexx/' contains example AREXX
  202. scripts that may be usefull. For example the command
  203.  
  204.     rx SetAutocompress XDH1 ON
  205.  
  206. will enable automatic compression on XDH1:.
  207.  
  208.  
  209.    Boolean options can be specified with "NO" / "OFF" or. "YES" / "ON". 
  210. String options are specified by simply putting the string after the 
  211. 'OPTION=' bit, no quotes are needed.
  212.  
  213. The available options are detailed below:
  214.  
  215.    ROOTDIR
  216.    VOLUMENAME
  217.    AUTOCOMPRESS
  218.    XSCAN
  219.    PACKMODE
  220.    STEPDOWN
  221.    PASSWORD
  222.    XPKPRIORITY
  223.    TRUNCATEONPACK
  224.    FAILONEXNEXT
  225.    KILLSTARTUP
  226.    COMPRESSREADWRITE
  227.    ALLOWAPPEND
  228.    PORTNAME
  229.    ENVOYKLUDGE
  230.  
  231. Option ROOTDIR:
  232.  
  233.    This option is used to set the name of the directory that XFH: is
  234. to reside in. For example 'ROOTDIR=Work:xfh' would cause XFH: to use
  235. that directory as root. Note that this option can only be used in the
  236. primary option file or directly in the mountlist. When used elsewhere
  237. it will simply be ignored. The default is to use the name of the XFH
  238. device itself with the first character removed (so XDH1: becomes
  239. DH1:). [Note that this is different from XFH v1.12 and earlier.]
  240.  
  241. Option VOLUMENAME:
  242.  
  243.    This option is used to set the name of the XFH: volume. This is the
  244. name that will be used in absolute path specifications, as well as the
  245. one returned by Info(). Ie. if you go 'VOLUMENAME=Manuals', access can
  246. be by 'Manuals:' as well as by 'XHn:' (or whatever). If this option is
  247. not specified, the default is to use the name of the directory in the
  248. underlying file system, or (if this is itself the root of a volume) to
  249. use the name with 'XFH_' prepended. Again, this is mainly for
  250. compatibility with early versions of XFH:. An alternative to using
  251. this option is to use the normal Relabel (from shell or WB); this will
  252. automatically create an entry for this option in the secondary option
  253. file (replacing any existing entry).
  254.  
  255. Option AUTOCOMPRESS:
  256.  
  257.    This options tells whether XFH: should attempt to compress the
  258. files written through it. When this option is set, everytime a file
  259. written to the XFH: is closed, an attempt will be made to compress the
  260. file to a temporary file using Xpk. If this is succesfull, the
  261. temporary file will be renamed to the original name and the
  262. uncompressed file will be deleted. If the compression fails for any
  263. reason, the uncompressed file will simply remain intact. This also
  264. means that if anything should go wrong during compression (like a disk
  265. full error), it is unlikely that any data will be lost since at least
  266. one of the two files should be intact (though possibly with a wierd
  267. name). This option is OFF by default.
  268.  
  269. Option XSCAN:
  270.  
  271.   This option tells whether XFH: should create xScan-like comment
  272. automatically. These comments will allow XFH to read directories much
  273. faster, see "xScan.doc" for more information. This option is OFF by
  274. default.
  275.  
  276. Option PACKMODE:
  277.  
  278.    This option selects the mode that Xpk should use when compressing
  279. files. It is specified in the usual way when using Xpk. For example,
  280. to use 12-bit BLZW compression, 'PACKMODE=BLZW.12' would be used. The
  281. default is to use the NUKE compression ('PACKMODE=NUKE'). Of course,
  282. to use a specific compression method, the nessesary sublibrary must be
  283. available in LIBS:.
  284.  
  285. Option STEPDOWN:
  286.  
  287.    This option controls the Xpk flag 'XPK_StepDown' during packing. If
  288. set, it means that Xpk is allowed to reduce packing efficiency if
  289. nessesary to save memory. Refer to the Xpk documentation for details.
  290. Default is OFF.
  291.  
  292. Option PASSWORD:
  293.  
  294.    This option is used to set the password that XFH: should pass on to
  295. Xpk when compressing or uncompressing. It should be noted that there
  296. is no attempt to keep this password safe from 'memory peekers'. Of
  297. course, storing the password in the option file isn't a good idea. A
  298. better idea is to use AREXX; the AREXX script 'SetPassword.rexx' in
  299. the directory 'Arexx/' may be helpful here. Note that if AUTOCOMPRESS
  300. is requested, files may still be saved unencrypted in low-memory or
  301. low-diskspace situations, and (depending on the underlying file system
  302. / disk device) part of the unencrypted data may still be physically
  303. stored on the disk after the deletion of the unencrypted file.
  304.  
  305.    If an attempt to open a file is made when XFH has been given the
  306. wrong password, the open will fail with error code 212 (Object wrong
  307. type).
  308.  
  309. Option XPKPRIORITY:
  310.  
  311.    This option is used to set the task priority that should be used
  312. when doing Xpk operations (compress/uncompress etc). Setting this to
  313. zero or less will prevent XFH from stealing all CPU-time from tasks
  314. running at a 'normal' priority. Note that it is possible to set the
  315. priority of the handler itself in the mountlist. If this option is not
  316. used, the handler will keep whatever priority it is running at when
  317. calling the Xpk library.
  318.  
  319. Option TRUNCATEONPACK:
  320.  
  321.    This option is somewhat technical in nature and can be safely
  322. ignored.  It is only used in case of an error occuring during the
  323. compression of a file. In this case, the compressed file has to be
  324. deleted, and if this option is set, the handler will try to call
  325. SetFileSize() first to truncate the file to 0 bytes (perhaps saving
  326. the flushing of a few buffers).  However, due to sparse documentation
  327. I'm uncertain whether this feature is stable, and hence it is OFF by
  328. default. Again, unless you are curious and don't mind risking
  329. crashes/data losses, forget about this option.
  330.  
  331. Option FAILONEXNEXT:
  332.  
  333. This option was included to solve a problem with some (or more likely
  334. most) programs that perform directory scanning.  The problem appears
  335. when listing a directory containing a file that is opened with an
  336. exclusive lock (for example, MODE_NEWFILE). In this case, XFH cannot
  337. determine the correct size of the file and thus fails with an
  338. appropriate error code. However, many programs just assume that the
  339. end of the directory has been reached. Setting this option to OFF will
  340. prevent XFH from reporting failure, returning a fileinfoblock with the
  341. wrong file size instead. Since this could result in data loss because
  342. programs will se the wrong file sizes, this option is ON by default.
  343.  
  344. Option KILLSTARTUP:
  345.  
  346. This option has been included to fix some problems with programs like
  347. 'Info' that examine data about file system handlers. It seems that
  348. these programs assume that the 'Startup' entry in the device node of
  349. any handler that supports volumes will be a FileSystemStartupMsg.
  350. However, in the case of XFH, it is a string. This behaviour seems to
  351. me to be completely unresonable, and thus a bug in these programs. The
  352. only way I could find to fix this was to have XFH manually erase the
  353. Startup field in the device node. This is not likely to be an
  354. officially supported way of poking the device node. Nevertheless, I
  355. had to agree that the problem is intolerable, and thus this option is
  356. on by default. However, it can be turned off if you have a mount
  357. command that does not like handlers that modify their device node.
  358.  
  359. Option COMPRESSREADWRITE:
  360.  
  361. This option controls whether new files opened with MODE_READWRITE will
  362. be compressed upon Close(). It is ON by default.
  363.  
  364. Option ALLOWAPPEND:
  365.  
  366. This option must be set to allow the writing to existing files (using
  367. MODE_READWRITE or MODE_OLDFILE). It is my personal opinion that
  368. compressed files shouldn't really be updated in place, since it
  369. requires first uncompressing the file on disk, then doing the Write(),
  370. then compressing the file again. However, some programs need this
  371. ability. This option is ON by default.
  372.  
  373. Option PORTNAME:
  374.  
  375. This option can be used to set the name of the AREXX port. This option
  376. can only be set in the option file or directly in the mountlist (no,
  377. you cannot set it using AREXX...). The default name is the same as the
  378. name of the XFH device.
  379.  
  380. Option ENVOYKLUDGE:
  381.  
  382. This option tells XFH: not to use ACTION_FH_FROM_LOCk for internal purpose
  383. to avoid trouble with the buggy implementation of this packet in Envoy FS.
  384. Without this kludge using a XFH: on a Envoy FS volume will crash the
  385. FileSystem on the server. The kludge may be not necessary for future
  386. version of Envoy. This option is OFF by default.
  387.  
  388.  
  389. In case of an error during the scanning of the option files the handler
  390. will fail its initialisation and hence refuse to load with error code 114
  391. (Bad Template). Sorry, but there are currently no real error messages
  392. implented (this will hopefully be fixed in a later version). If the handler
  393. refuses to work for no apparent reason, be sure to tripple-check your
  394. option files for errors.
  395.  
  396.  
  397.  
  398.  
  399.                               --- O ---
  400.  
  401.  
  402. Limitations and known bugs.
  403.  
  404.    The error detection code in the initialisation part of the handler is 
  405. somewhat flaky - I've tried to make it resonably safe, but documentation 
  406. on the right way to start a handler is hard to find. What it means is 
  407. that it is a good idea to make sure that the handler is placed in L: and
  408. that the nessesary Xpk libraries are placed in libs: before starting the 
  409. handler (remember, XFH won't be able to tell you the reason if it was 
  410. unable to initialise for some reason). Another subtle problem is that due 
  411. to a quirk of the device list locking, it is vital (using XFH v1.39) that 
  412. the handler for the directory that XFH is to sit in is already loaded. 
  413. Usually this will not be a problem; however, if you are using 3rd party 
  414. filesystem handlers that are mounted after boot-up, you can avoid 
  415. problems by accessing them before mounting XFH (for example by creating 
  416. an assign (not late-binding) to them).
  417.  
  418.    It should be noted that the way the XFH makes the same files
  419. available by two different routes is not without its problems. One
  420. problem is connected to the volume name - XFH tries to be smart about
  421. it, but it will sometimes create a duplicate volume name which is a
  422. bad idea. To solve this problem the VOLUMENAME option should be used
  423. in an option file, or the XFH volume should be changed with Relabel.
  424. Another problem when mounting XFH in the root dir appears when using
  425. the 'Leave Out' feature of the 2.0 Workbench. Here, the '.backdrop' is
  426. duplicated in both volumes, making the left-out icons appear twice.
  427. I'm working on a decent solution to this problem. Meanwhile, I would
  428. recommend that XFH is mounted only on top of subdirectories.
  429.  
  430. To provide maximum transparency for application programs, both of the
  431. options AUTOCOMPRESS and ALLOWAPPEND should be set. This will make XFH
  432. compress files that are written to it 'on the fly', even for programs
  433. that update existing files (ie MODE_READWRITE, 'append mode', shell
  434. '>>' redirection etc). However, a bit of care is advised when using
  435. the ALLOWAPPEND option. For example, it is obviously not a good idea
  436. to have two programs writing to the same compressed file at the same
  437. time. Even worse, if one program is accessing a file on the underlying
  438. file system at the same time that another program is writing to the
  439. same file using XFH, XFH is unable to guard completely against data
  440. loss. Bevare of this situation. Another thing is that writing to a
  441. compressed file opened with MODE_OLDFILE (like Lha does) relies on the
  442. ACTION_CHANGE_MODE packet (to partially solve the problems just
  443. mentioned), and thus won't work using KS1.3 file systems or some file
  444. systems written before the apperance of KS2.0.
  445.  
  446.    Needless to say (but I'll say it anyway), you should not assign libs: 
  447. to a XFH unit unless you are absolutely sure of what you are doing. A 
  448. nice trap is to have the XFH call (and wait for) Xpk, which will then wait
  449. for XFH to load a particular library for it.
  450.  
  451.    It should be noted that any given unit of the XFH binds to a directory, 
  452. not to a DOS device. This means that, currently, it is not possible to 
  453. have a XFH unit working like DFx: - any access will refer to the disk that 
  454. was in the drive when the handler was started, not to the disk currently 
  455. in the drive.
  456.  
  457.    The figures reported by the shell 'Info' command are somewhat strange.
  458. The problem is that it isn't really possible to give sensible figures for
  459. 'NumBlocks' and 'NumBlocksUsed'. Currently, their values are the same as
  460. those for the underlying file system.
  461.  
  462.    XFH has problems with exclusive locks (for example trying to obtain an 
  463. exclusive lock on "/" or "foo//" will always fail).
  464.  
  465.    Some people have experienced problems when using XFH with the 
  466. arp.library. This is because a bug/feature in the apr.library function 
  467. CompareLock() (it declares two locks equal only if the lock->fl_Key 
  468. fields are equal, which is illegal according to the 2.0 DOS manual). 
  469. Under 2.0, the program in the directory 'patcharp' can be used to patch 
  470. arp to use the correct 2.0 SameLock() call. Also, I know of a program 
  471. that remaps the arp calls to the corresponding 2.0 dos.library calls 
  472. (though I haven't tried it), it might help too.
  473.  
  474.  
  475.  
  476.                               --- O ---
  477.  
  478.  
  479. Theory of operation.
  480.  
  481.    XFH works by installing itself in the system as a file system handler 
  482. like DF0: or RAM:. However, unlike most file system handlers, which sit on 
  483. top of a device (or rest in themselves like RAM:), XFH sits on top of an 
  484. underlying file system handler (abbrevated to UFS) containing a mixture 
  485. of normal and compressed files. After initialising itself, XFH sits in a 
  486. loop receiving packets from AmigaDOS and other applications. Each packet 
  487. is examined and the appropriate action taken. For example, an open request 
  488. will cause XFH to open the given file, check whether it is compressed, and 
  489. if so unpack it to memory for later read requests.
  490.  
  491.    XFH is currently single-threaded, unlike the Commodore file systems 
  492. (this means that it is not possible for the XFH to service other requests 
  493. while waiting for the UFS). I'm hoping to fix this in some later version.
  494.  
  495.  
  496.  
  497.                               --- O ---
  498.  
  499.  
  500. Acknowledgments.
  501.  
  502.    The author wishes to thank all the people that have participated in 
  503. the development of Xpk without which the XFH would not have been the 
  504. same. I am especially grateful to Urban D. Müller for helping me start
  505. the whole concept of the XFH back in the summer of 1991 - without his 
  506. help the XFH is not likely to have been realised. Thanks also to the many 
  507. beta testers who helped me iron out as many bugs as possible before 
  508. release; your help work has been very valuable to me. And thanks must 
  509. go, of course, to the guys at Commodore for bringing to us the wonderful 
  510. Amiga.
  511.